﻿package ua.mihaylenko.cardsplugin.common
{	
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.system.Security;
	import flash.display.StageAlign;
	import flash.display.StageQuality;
	import flash.display.StageScaleMode;
	public dynamic class DocumentClass extends MovieClip
	{
		public static var AppStage:Stage;
		public static var Url:String;
		public var _smcPreLoader:MovieClip;
		
		public function DocumentClass(){
			
			this.stop();
			
			this.tabEnabled = false;
			//this.tabChildren = false;
			stage.showDefaultContextMenu = false;
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.quality = StageQuality.BEST;
			Security.allowDomain("*");
			AppStage = stage;
			this.addEventListener(Event.ENTER_FRAME, enterFrameListener);
			_smcPreLoader._stxPercent.mouseEnabled = false;
			
			Url = this.loaderInfo.url;
		}
		private function enterFrameListener(oEvent:Event){
			if ( this.framesLoaded == this.totalFrames ){
                this.removeEventListener( Event.ENTER_FRAME, enterFrameListener );
				//this is important because it will load the art that is set to not load on the first frame
               	this.gotoAndStop("start");
            }else{
                var nPercentComplete:Number = this.loaderInfo.bytesLoaded / this.loaderInfo.bytesTotal;
				
				_smcPreLoader._smcLoadBar._smcPercent.scaleX = nPercentComplete;
				_smcPreLoader._stxPercent.text = Math.round( nPercentComplete * 100 ) + "%";
            }
		}
	}
}
